// N 茶树 前序遍历
var preorder = function (root) {
  let output = []
  if (!root) return output
  let stack = [root]
  while (stack.length) {
    let node = stack.pop()
    if (node) {
      output.push(node.val)
      node.children.reverse()
      for (let item of node.children) {
        stack.push(item)
      }
    }
  }
  return output
}
